Skip to content

Conversation

@randy-cro
Copy link

@randy-cro randy-cro commented Nov 13, 2025

Description

This patch introduces a fixed gas consumption decorator in the antehandler to standardize gas usage for whitelisted messages.
Currently, only staking-related messages are included in the whitelist.

⚠️ Version Note:
As this is a v1.5 patch, all staking-related operations will be rejected at the antehandler level.
This serves as a warning for node operators about potential AppHash mismatches if inconsistent gas consumption is detected.


Purpose

This ensures consistent gas consumption across all nodes, regardless of variations in staking cache size.
By normalizing gas usage, it prevents potential AppHash mismatches caused by node-specific performance differences.

Implementation Details

  • A fixed gas amount is assigned per whitelisted message type.
  • The values are derived from the average gas usage observed on mainnet.

For example, the mean gas used for MsgUndelegate can be referenced here:
Mainnet reference

This change works in tandem with the staking cache introduced in the Cosmos SDK:
crypto-org-chain/cosmos-sdk#1733


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@randy-cro randy-cro requested a review from a team as a code owner November 13, 2025 07:39
@randy-cro randy-cro requested review from JayT106 and songgaoye and removed request for a team November 13, 2025 07:39
@randy-cro randy-cro changed the title fix:staking optimization fix: staking optimization Nov 13, 2025
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 83.92857% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.88%. Comparing base (1544264) to head (2498a08).
⚠️ Report is 1 commits behind head on release/v0.22.x-cronosv1.6-optstaking.

Files with missing lines Patch % Lines
ante/cosmos/reject_staking.go 43.75% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                            Coverage Diff                            @@
##           release/v0.22.x-cronosv1.6-optstaking     #779      +/-   ##
=========================================================================
+ Coverage                                  46.75%   46.88%   +0.12%     
=========================================================================
  Files                                        187      189       +2     
  Lines                                      15221    15275      +54     
=========================================================================
+ Hits                                        7117     7162      +45     
- Misses                                      7316     7325       +9     
  Partials                                     788      788              
Files with missing lines Coverage Δ
ante/cosmos/fixed_gas.go 100.00% <100.00%> (ø)
evmd/ante/evm_handler.go 100.00% <100.00%> (ø)
evmd/ante/handler_options.go 61.45% <100.00%> (+0.82%) ⬆️
evmd/app.go 78.64% <100.00%> (+0.23%) ⬆️
ante/cosmos/reject_staking.go 43.75% <43.75%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 2 times, most recently from 2cbdd91 to c404b83 Compare November 13, 2025 08:09
@randy-cro randy-cro changed the title fix: staking optimization fix: staking optimization v1.5.x patch Nov 13, 2025
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from c404b83 to a64e281 Compare November 13, 2025 09:58
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 7 times, most recently from d2d7d02 to b338cac Compare November 18, 2025 03:26
Copy link

@JayT106 JayT106 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 3 times, most recently from a2d9338 to 7e9c1c2 Compare November 19, 2025 11:14
@randy-cro randy-cro changed the title fix: staking optimization v1.5.x patch fix: staking optimization v1.6.x patch Nov 20, 2025
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 7e9c1c2 to 5ac5695 Compare November 21, 2025 09:24
@randy-cro randy-cro changed the base branch from release/v0.22.x to release/v0.22.x-cronosv1.6-optstaking November 21, 2025 09:25
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 2 times, most recently from a7e326e to 5ac5695 Compare November 21, 2025 11:01
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 5ac5695 to ec97211 Compare November 24, 2025 02:34
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from ec97211 to 618ed05 Compare November 24, 2025 03:08
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 618ed05 to 867d593 Compare November 24, 2025 03:40
@socket-security
Copy link

socket-security bot commented Nov 24, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​crypto-org-chain/​cosmos-sdk@​v0.50.6-0.20250424063720-28ea58ae20d8 ⏵ v0.0.0-20251121110054-d5e74b9954c176 +1100100100100

View full report

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 867d593 to 727854b Compare November 24, 2025 07:01
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 727854b to 2498a08 Compare November 24, 2025 08:39
@randy-cro randy-cro merged commit 12d426c into crypto-org-chain:release/v0.22.x-cronosv1.6-optstaking Nov 24, 2025
29 of 35 checks passed
@randy-cro randy-cro deleted the fix/staking-optimization-1.5.x-patch branch November 24, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants